﻿using System;
using Rainbow.ObjectFlow.Interfaces;
using Rainbow.ObjectFlow.Language;

namespace Rainbow.ObjectFlow.Framework
{
    ///<summary>
    /// Provides functionality common to all workflows and interfaces to configure and start workflows
    ///</summary>
    ///<typeparam name="T">Type the workflow transforms</typeparam>
    public abstract class AsAWorkflow<T> : IConfigureSequence<T>, IExecuteWorkflow<T> where T : class
    {
        /// <summary>
        /// Allows a workflow operations and policies to be added
        /// </summary>
        /// <returns></returns>
        public abstract IWorkflow<T> Configure();

        ///<summary>
        /// Start a worfklow
        ///</summary>
        ///<returns>Transformed data of T</returns>
        public virtual T Start()
        {
            return Start(default(T));
        }

        ///<summary>
        /// Start workflow
        ///</summary>
        ///<param name="seedData">Data that the first operation works on.</param>
        ///<returns>Transformed data of T</returns>
        public virtual T Start(T seedData)
        {
            return Configure().Start(seedData);
        }
    }
}